<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script src="script-tags-for-development.js"></script>
<script>
    var app = angular.module('myApp', ['ngMap']);
    app.controller('MarkerRemoveCtrl', function(NgMap) {
      var vm = this;
      NgMap.getMap().then(map => vm.map = map);
      vm.positions = [{lat:37.7699298,lng:-122.4469157}];

      vm.addMarker = function(event) {
        var ll = event.latLng;
        vm.positions.push({lat:ll.lat(), lng: ll.lng()});
      }
      vm.deleteMarkers = function() {
        vm.positions = [];
      };
      vm.showMarkers = function() {
        for (var key in vm.map.markers) {
          vm.map.markers[key].setMap(vm.map);
        };
      };
      vm.hideMarkers = function() {
        for (var key in vm.map.markers) {
          vm.map.markers[key].setMap(null);
        };
      };
    });
</script>
</head>

<body>
  <style>
    div[ng-controller] {
      position: relative;
    }
    #panel {
      position: absolute;
      top: 40px;
      left: 50%;
      margin-left: -180px;
      z-index: 5;
      background-color: #fff;
      padding: 5px;
      border: 1px solid #999;
    }
  </style>
    <div ng-controller="MarkerRemoveCtrl as vm">
      Remove Markers<br/>
      Click on map to add a marker. Click button to show, hide, or remove markers<br/>
      <div id="panel">
        <input ng-click="vm.hideMarkers()" type=button value="Hide Markers">
        <input ng-click="vm.showMarkers()" type=button value="Show All Markers">
        <input ng-click="vm.deleteMarkers()" type=button value="Delete Markers">
      </div>
      <ng-map center="37.7699298, -122.4469157" zoom="12" on-click="vm.addMarker()">
        <marker
          ng-repeat="pos in vm.positions" position="{{pos.lat}}, {{pos.lng}}"
          icon="{path:'CIRCLE', scale: 10, strokeColor: 'red', zIndex:10}"></marker>
        <marker position="37.7899298, -122.4469157"
          icon="{path:'CIRCLE', scale: 10, strokeColor: 'red', zIndex:12}"></marker>
        <marker position="37.7799298, -122.4469157"
          icon="{path:'CIRCLE', scale: 10, strokeColor: 'green', zIndex:11}"></marker>
        <marker position="37.7699298, -122.4469157"
          icon="{path:'CIRCLE', scale: 10, strokeColor: 'blue', zIndex:10}"></marker>
      </ng-map>
    </div>
</body>
</html>
